package id.net.iconpln.bb.client.view;

import id.net.iconpln.bb.client.model.BbMstPembangkitBean;
import id.net.iconpln.bb.client.model.Stock;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.table.NumberCellRenderer;
import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Element;

public class PageBbTransportSurveyor extends LayoutContainer {
	private FormBinding formBindings;  
	private FormData formData; 
	private Grid<Stock> grid;
	private Grid<BbMstPembangkitBean> gridpltu;
	private Grid<BbMstPembangkitBean>  gridship;
	
	  @Override  
	  protected void onRender(Element parent, int index) {  
	    super.onRender(parent, index);  
	    setLayout(new FitLayout());
	    
	    formData = new FormData("-20"); 
	    ContentPanel cp = new ContentPanel();  
	   
	    cp.setHeaderVisible(false);
	    cp.setFrame(true);  
	    cp.setSize(900, 400);  
	    cp.setLayout(new RowLayout(Orientation.HORIZONTAL)); 
//	    cp.setLayout(new RowLayout(Orientation.VERTICAL));	  
	  
	    grid = createGrid();  
	    grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    grid.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<Stock>>() {  
	          public void handleEvent(SelectionChangedEvent<Stock> be) {  
	            if (be.getSelection().size() > 0) {  
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    ToolBar tbJadwal = new ToolBar();
	    tbJadwal.add(new LabelToolItem("<b>Data Jadwal Pengiriman</b>"));
	    tbJadwal.add(new SeparatorToolItem());
	    
	    
	    
	    gridpltu = createGridPltu();
	    ToolBar tbPltu = new ToolBar();
	    tbPltu.add(new LabelToolItem("<b>Data Penugasan Sampling</b>"));
	    tbPltu.add(new SeparatorToolItem());
	    	    
	    gridship = createGridPreshipment();
	    ToolBar tbShip = new ToolBar();
	    tbShip.add(new LabelToolItem("<b>Data Surveyor</b>"));
	    tbShip.add(new SeparatorToolItem());
	    
	    FormPanel panel = createForm(); 
	    panel.setScrollMode(Scroll.AUTO);
	    formBindings = new FormBinding(panel, true);  
	    formBindings.setStore((Store) grid.getStore());  
	    
	    
	    ContentPanel pkirim = new ContentPanel();
	    pkirim.setHeaderVisible(false);
	    pkirim.setLayout(new FitLayout());
	    pkirim.add(gridpltu);
	    pkirim.setTopComponent(tbPltu);
	    
//	    ContentPanel p = new ContentPanel();
//	    p.setHeaderVisible(false);
////	    p.setLayout(new RowLayout(Orientation.VERTICAL));	    	    
////	    p.add(panel, new RowData(.99, .99));
//	    p.add(pkirim, new RowData(.5, .99));
//	    p.setTopComponent(tbPltu);

	    ContentPanel pg = new ContentPanel();
	    pg.setHeaderVisible(false);
	    pg.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pg.add(gridship,new RowData(.99, 1));
	    pg.setTopComponent(tbShip);
	    
	    cp.add(pg, new RowData(.4, 1));
	    cp.add(pkirim, new RowData(.6, 1));
	    
	    
//		setScrollMode(Scroll.AUTO);		
	    add(cp, new FitData(5));  
	  }  
	  
	  private Grid<BbMstPembangkitBean> createGridPreshipment(){
		    final NumberFormat currency = NumberFormat.getCurrencyFormat();  
		    final NumberFormat number = NumberFormat.getFormat("0.00");  
		    final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(  
		        currency);  
		  
		    GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() {  
		  
		      public String render(Stock model, String property, ColumnData config, int rowIndex,  
		          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {  
		        double val = (Double) model.get(property);  
		        String style = val < 0 ? "red" : "green";  
		        return "<span style='color:" + style + "'>" + number.format(val) + "</span>";  
		      }  
		    };  
		  
		    GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {  
		      public String render(Stock model, String property, ColumnData config, int rowIndex,  
		          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {  
		        return numberRenderer.render(null, property, model.get(property));  
		      }  
		    };  
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    

		    column = new ColumnConfig();  
		    column.setId("nama_pembangkit");  
		    column.setHeader("Nama");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("PIC");  
		    column.setWidth(100);  
		    configs.add(column);  	
		    
		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("Alamat");  
		    column.setWidth(100);  
		    configs.add(column);  	  
		    
		    
//		    column = new ColumnConfig();  
//		    column.setId("pemasok");  
//		    column.setHeader("Jumlah Dermaga");  
//		    column.setWidth(100);  
//		    configs.add(column);  

//		    
//		    column = new ColumnConfig();  
//		    column.setId("nama_pembangkit");  
//		    column.setHeader("No Rakor");    
//		    column.setWidth(100);    
//		    configs.add(column);  
//		    
//		  
//		    column = new ColumnConfig();  
//		    column.setId("tonase");  
//		    column.setHeader("Jetty / Dermaga");    
//		    column.setWidth(100);    
//		    configs.add(column);
//
//		    	            		      
//		    column = new ColumnConfig();  
//		    column.setId("kualitas");  
//		    column.setHeader("Status");    
//		    column.setWidth(150);  
//		    configs.add(column);
		    		    
		    
		    ListStore<BbMstPembangkitBean> store = new ListStore<BbMstPembangkitBean>();  
		    store.setMonitorChanges(true);  
//		    store.add(TestData.getMstPembangkit());
		  
		    ColumnModel cm = new ColumnModel(configs);  
		  
		    Grid<BbMstPembangkitBean> gridship = new Grid<BbMstPembangkitBean>(store, cm);  
		    gridship.getView().setEmptyText("Data Empty");  
		    gridship.setBorders(false);  
//		    grid.setAutoExpandColumn("pemasok");  
		    gridship.setBorders(true);  
		  
		    return gridship;  
		  }   
	  
	  private FormPanel createForm() {  
	    FormPanel panel = new FormPanel();	    
	    panel.setHeaderVisible(false);
	    
	    FieldSet fieldSet = new FieldSet();  
	    fieldSet.setHeading("Pengajuan Loading");  
	    fieldSet.setCollapsible(false);
	    
	  
	    FormLayout layout = new FormLayout();  
	    layout.setLabelWidth(180);  
	    fieldSet.setLayout(layout);  

	    TextField<String> noPengirimans = new TextField<String>();  
	    noPengirimans.setName("noPengiriman");  
	    noPengirimans.setFieldLabel("No Shipment");    
	    fieldSet.add(noPengirimans, formData);	  	  
	    
	    TextField<String> noPengiriman = new TextField<String>();  
	    noPengiriman.setName("noPengiriman");  
	    noPengiriman.setFieldLabel("No Rakor");    
	    fieldSet.add(noPengiriman, formData);	  	  
	    	     

	    TextField<String> noKontrak = new TextField<String>();	    
	    noKontrak.setName("noKontrak");  
	    noKontrak.setFieldLabel("No Jadwal");    
	    fieldSet.add(noKontrak, formData);

	    TextField<String> pemasok = new TextField<String>();	    
	    pemasok.setName("pemasok");  
	    pemasok.setFieldLabel("Tanggal");    
	    fieldSet.add(pemasok, formData);
	    
	    TextField<String> noKontrakd = new TextField<String>();	    
	    noKontrakd.setName("noKontrak");  
	    noKontrakd.setFieldLabel("ETA");    
	    fieldSet.add(noKontrakd, formData);

	    TextField<String> pemasoka = new TextField<String>();	    
	    pemasoka.setName("pemasok");  
	    pemasoka.setFieldLabel("ETD");    
	    fieldSet.add(pemasoka, formData);	    	    


	    TextField<String> tonase = new TextField<String>();
	    tonase.setName("tonase");  
	    tonase.setFieldLabel("Vol Kirim (Ton)");	    
	    fieldSet.add(tonase, formData);

	    TextField<String> kualitas = new TextField<String>();
	    kualitas.setName("kualitas");  
	    kualitas.setFieldLabel("Kualitas (kalori)");	    
	    fieldSet.add(kualitas, formData);
	    	
	    TextField<String> namakpl = new TextField<String>();
	    namakpl.setName("namakpl");  
	    namakpl.setFieldLabel("Nama Kpl / Tongkang");	    
	    fieldSet.add(namakpl, formData);
	    
	    TextField<String> pic = new TextField<String>();
	    pic.setName("pic");  
	    pic.setFieldLabel("PIC");	    
	    fieldSet.add(pic, formData);
	    
	    
	    panel.add(fieldSet);  	     

//	    
//	    FieldSet fieldSet2 = new FieldSet();  
//	    fieldSet2.setHeading("ETA");  
//	    fieldSet2.setCollapsible(false);
//	    
//	    FormLayout layout2 = new FormLayout();  
//	    layout2.setLabelWidth(100);  
//	    fieldSet2.setLayout(layout2);  	       	    	   
//
//	    TextField<String> asal = new TextField<String>();	    
//	    asal.setName("asalbb");  
//	    asal.setFieldLabel("Asal batubara");    
//	    fieldSet2.add(asal, formData);
//
//	    
//	    TextField<String> pltutj = new TextField<String>();	    
//	    pltutj.setName("pltuj");  
//	    pltutj.setFieldLabel("PLTU tujuan");    
//	    fieldSet2.add(pltutj, formData);
//
//	    
//	    TextField<String> berangkat = new TextField<String>();
////	    DateField berangkat = new DateField();
//	    berangkat.setName("berangkat");  
//	    berangkat.setFieldLabel("Tgl kirim");    
//	    fieldSet2.add(berangkat, formData);	    	    	    
//	    
//	    TextField<String> tiba = new TextField<String>();
////	    DateField tiba = new DateField();
//	    tiba.setName("tiba");  
//	    tiba.setFieldLabel("Tgl tiba");    
//	    fieldSet2.add(tiba, formData);
//	    
//	    panel.add(fieldSet2);
//	    
//	    
//	    FieldSet fieldSet3 = new FieldSet();  
//	    fieldSet3.setHeading("Data Transportasi");  
//	    fieldSet3.setCollapsible(false);
//
//	    FormLayout layout3 = new FormLayout();  
//	    layout3.setLabelWidth(160);  
//	    fieldSet3.setLayout(layout3);  

	    
//	    CheckBox check1 = new CheckBox();  
//	    check1.setBoxLabel("Manifest");  
//	  
//	    CheckBox check2 = new CheckBox();  
//	    check2.setBoxLabel("Sertifikat kalori");  
//	    check2.setValue(true);  
//	  
//	    CheckBox check3 = new CheckBox();  
//	    check3.setBoxLabel("Sertifikat Weight");  
//	  
//	    CheckBoxGroup checkGroup = new CheckBoxGroup();  
//	    checkGroup.setFieldLabel("Lampiran");  
//	    checkGroup.add(check1);  
//	    checkGroup.add(check2);  
//	    checkGroup.add(check3);  
//	    fieldSet2.add(checkGroup, formData);
	    	    	   
//	    TextField<String> namakpl = new TextField<String>();
//	    namakpl.setName("namakpl");  
//	    namakpl.setFieldLabel("Nama Kpl / Tongkang");	    
//	    fieldSet3.add(namakpl, formData);
//	    
//	    TextField<String> pic = new TextField<String>();
//	    pic.setName("pic");  
//	    pic.setFieldLabel("PIC");	    
//	    fieldSet3.add(pic, formData);
//	    
//	    TextField<String> notlp = new TextField<String>();
//	    notlp.setName("notlp");  
//	    notlp.setFieldLabel("No Tlp");	    
//	    fieldSet3.add(notlp, formData);
//	    
//	    TextField<String> pkpl = new TextField<String>();
//	    pkpl.setName("pkpl");  
//	    pkpl.setFieldLabel("Pemilik Kpl / Tonkang");	    
//	    fieldSet3.add(pkpl, formData);
//	    
//	    TextField<String> muatan = new TextField<String>();
//	    muatan.setName("muatan");  
//	    muatan.setFieldLabel("Kapsitas Kpl / tkg (Ton)");	    
//	    fieldSet3.add(muatan, formData);
//	  
//	    TextField<String> jkpl = new TextField<String>();
//	    jkpl.setName("jkpl");  
//	    jkpl.setFieldLabel("Jml Kpl / Tkg");	    
//	    fieldSet3.add(jkpl, formData);
//	    
//	    panel.add(fieldSet3);

	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);	    
	    p.setButtonAlign(HorizontalAlignment.RIGHT);  
	    p.addButton(new Button("Reset", new SelectionListener<ButtonEvent>() {  
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  
	        grid.getStore().rejectChanges();  
	      }  
	    }));  
	    p.addButton(new Button("Submit", new SelectionListener<ButtonEvent>() {  
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  
	        grid.getStore().commitChanges();  
	      }  
	    }));  

	    panel.add(p);
	    
	    return panel;  
	  }  

	  private Grid<BbMstPembangkitBean> createGridPltu(){
		    final NumberFormat currency = NumberFormat.getCurrencyFormat();  
		    final NumberFormat number = NumberFormat.getFormat("0.00");  
		    final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(  
		        currency);  
		  
		    GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() {  
		  
		      public String render(Stock model, String property, ColumnData config, int rowIndex,  
		          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {  
		        double val = (Double) model.get(property);  
		        String style = val < 0 ? "red" : "green";  
		        return "<span style='color:" + style + "'>" + number.format(val) + "</span>";  
		      }  
		    };  
		  
		    GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {  
		      public String render(Stock model, String property, ColumnData config, int rowIndex,  
		          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {  
		        return numberRenderer.render(null, property, model.get(property));  
		      }  
		    };  
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    
//		    column = new ColumnConfig();  
//		    column.setId("nama_pembangkit");  
//		    column.setHeader("Pembangkit");    
//		    column.setWidth(150);    
//		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("Pembangkit");  
		    column.setWidth(100);  
		    configs.add(column);  	

		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("Kapasitas");  
		    column.setWidth(100);  
		    configs.add(column);  	  

		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("No PJBB");  
		    column.setWidth(100);  
		    configs.add(column);  	  

		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("Tgl PJBB");  
		    column.setWidth(100);  
		    configs.add(column);  	 
		    
		    column = new ColumnConfig();  
		    column.setId("noKontrak");  
		    column.setHeader("Alamat");  
		    column.setWidth(100);  
		    configs.add(column);  
		    
//		    column = new ColumnConfig();  
//		    column.setId("noKontrak");  
//		    column.setHeader("KButuhan Thn");  
//		    column.setWidth(100);  
//		    configs.add(column); 
//		    
//		    column = new ColumnConfig();  
//		    column.setId("noKontrak");  
//		    column.setHeader("Vol (Ton)");  
//		    column.setWidth(100);  
//		    configs.add(column);  	  
//
//		    column = new ColumnConfig();  
//		    column.setId("noKontrak");  
//		    column.setHeader("RP / Ton");  
//		    column.setWidth(100);  
//		    configs.add(column); 
//		    
//		    column = new ColumnConfig();  
//		    column.setId("noKontrak");  
//		    column.setHeader("Hrg Penyesuaian");  
//		    column.setWidth(100);  
//		    configs.add(column); 
//		    
//		    
//		    
//		    column = new ColumnConfig();  
//		    column.setId("tonase");  
//		    column.setHeader("Jml Jetty");    
//		    column.setWidth(100);    
//		    configs.add(column);


		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Kalori");  
		    column.setWidth(70);  
		    configs.add(column);  


		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Masa Berlaku");  
		    column.setWidth(100);  
		    configs.add(column);  
		    

		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Jenis Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  
		    
//		    column = new ColumnConfig();  
//		    column.setId("pemasok");  
//		    column.setHeader("Jaminan Bank");  
//		    column.setWidth(100);  
//		    configs.add(column);  
		    
		    ListStore<BbMstPembangkitBean> store = new ListStore<BbMstPembangkitBean>();  
		    store.setMonitorChanges(true);  
//		    store.add(TestData.getMstPembangkit());
		  
		    ColumnModel cm = new ColumnModel(configs);  
		  
		    Grid<BbMstPembangkitBean> gridpltu = new Grid<BbMstPembangkitBean>(store, cm);  
		    gridpltu.getView().setEmptyText("Data Empty");  
		    gridpltu.setBorders(false);  
//		    grid.setAutoExpandColumn("pemasok");  
		    gridpltu.setBorders(true);  
		  
		    return gridpltu;  
		  }   
	 
	  
	  private Grid<Stock> createGrid() {  
	    final NumberFormat currency = NumberFormat.getCurrencyFormat();  
	    final NumberFormat number = NumberFormat.getFormat("0.00");  
	    final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(  
	        currency);  
	  
	    GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() {  
	  
	      public String render(Stock model, String property, ColumnData config, int rowIndex,  
	          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {  
	        double val = (Double) model.get(property);  
	        String style = val < 0 ? "red" : "green";  
	        return "<span style='color:" + style + "'>" + number.format(val) + "</span>";  
	      }  
	    };  
	  
	    GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {  
	      public String render(Stock model, String property, ColumnData config, int rowIndex,  
	          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {  
	        return numberRenderer.render(null, property, model.get(property));  
	      }  
	    };  
	  
	    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

	    ColumnConfig column = new ColumnConfig();	    	     
	    
	    column = new ColumnConfig();  
	    column.setId("noPengiriman");  
	    column.setHeader("Tanggal");    
	    column.setWidth(150);    
	    configs.add(column);  

	    column = new ColumnConfig();  
	    column.setId("noKontrak");  
	    column.setHeader("Transportir");  
	    column.setWidth(100);  
	    configs.add(column);  	  
	    
//	    column = new ColumnConfig();  
//	    column.setId("pemasok");  
//	    column.setHeader("Vol(ton)");  
//	    column.setWidth(150);  
//	    configs.add(column);  
//	  

	    
//	    column = new ColumnConfig();  
//	    column.setId("asalbb");  
//	    column.setHeader("Asal");    
//	    column.setWidth(150);  
//	    configs.add(column);
//	    
//	    column = new ColumnConfig();  
//	    column.setId("pltuj");  
//	    column.setHeader("PLTU Tj");    
//	    column.setWidth(150);  
//	    configs.add(column);
	    
	    column = new ColumnConfig();  
	    column.setId("berangkat");  
	    column.setHeader("ETA");    
	    column.setWidth(75);   
	    configs.add(column);
	    
	    column = new ColumnConfig();  
	    column.setId("tiba");  
	    column.setHeader("ETD");    
	    column.setWidth(100);  
	    configs.add(column);
	   	    	    
	    column = new ColumnConfig();  
	    column.setId("namakpl");  
	    column.setHeader("Nama Kpl / Tkg");    
	    column.setWidth(100);    
	    configs.add(column);
	   
	    column = new ColumnConfig();  
	    column.setId("tonase");  
	    column.setHeader("Vol (Ton)");    
	    column.setWidth(100);    
	    configs.add(column);

	    	            	      
	    column = new ColumnConfig();  
	    column.setId("kualitas");  
	    column.setHeader("Kualitas (kal)");    
	    column.setWidth(150);  
	    configs.add(column);
	    
	    column = new ColumnConfig();  
	    column.setId("pic");  
	    column.setHeader("PIC");    
	    column.setWidth(100);    
	    configs.add(column);
	    
//	    column = new ColumnConfig();  
//	    column.setId("jkpl");  
//	    column.setHeader("Jml Kpl / Tkg");    
//	    column.setWidth(100);    
//	    configs.add(column);
	    
	    
	    ListStore<Stock> store = new ListStore<Stock>();  
	    store.setMonitorChanges(true);  
//	    store.add(TestData.getJadwalkirim("k"));
	  
	    ColumnModel cm = new ColumnModel(configs);  
	  
	    Grid<Stock> grid = new Grid<Stock>(store, cm);  
	    grid.getView().setEmptyText("Data Empty");  
	    grid.setBorders(false);  
//	    grid.setAutoExpandColumn("pemasok");  
	    grid.setBorders(true);  
	  
	    return grid;  
	  }
}
